Publish Your Bot on PubNub
Get callback URL and sample code
- Log in to the Gupshup website
- Go to the Dashboard tab > My Bots section.
- Select the Channel button under the Publish column against the bot you wish to publish.
- A list of channels will appear. Click on the Publish button against PubNub.
- Scroll down and click Setup PubNub function to call Gupshup bot using XHR module.
- Copy the Callback URL and sample code for later use.
![PN 4.png Sample code and Callback URL](https://files.readme.io/bd92a0f-PN_4.png)
Sample code and Callback URL
Create a PubNub function
- Log in to your PubNub account. Sign up if you don't have a PubNub account.
- Navigate to the Functions tab in the sidebar.
- Click on the All apps drop-down menu and select My First App.
![All Apps dropdown](https://files.readme.io/6d5cfd0-Screenshot_2023-02-15_at_10.43.18_PM.png)
All Apps dropdown
- Click on the + CREATE NEW MODULE button.
- Provide the module name, and module description and select the keyset from the drop-down menu. Click Create.
- Click and open the function module you just created.
![List of functions](https://files.readme.io/4b41c73-Screenshot_2023-02-15_at_10.56.16_PM.png)
List of functions
- Click on the + CREATE NEW FUNCTION button.
- Provide a function and select the event type as After Publish or Fire from the drop-down menu.
- A new field titled Channel name will appear. Enter the channel name starting with Gupshup. For example: Gupshup.demo.
![Create a new function](https://files.readme.io/8d7c0d8-Screenshot_2023-02-15_at_11.03.53_PM.png)
Create a new function
- Click the Create button.
Configure the PubNub function to call the Gupshup bot
- Use the callback URL and sample code copied earlier from the Gupshup website to set up the PubNub function to call the bot using the XHR module.
- Click on the Save button present in the left sidebar.
![PN 5.png Save button](https://files.readme.io/2c04ff8-PN_5.png)
Save button
Get Publish Key and Subscribe Key from PubNub
- Go to the Home page of your PubNub account.
- Go to Keysets in the sidebar.
- Click on All Apps and select the App in which you created the function.
- Copy the PUBLISH KEY and SUBSCRIBE KEY for later use.
![Publish key and subscribe key](https://files.readme.io/401c306-Screenshot_2023-02-15_at_11.14.39_PM.png)
Publish key and subscribe key
Submit credentials
- Log in to the Gupshup website.
- Go to the Dashboard tab > My Bots section.
- Select the Channel button under the Publish column against the bot you wish to publish.
- A list of channels will appear. Click on the Publish button against PubNub.
- Scroll down and click Submit Publish Key and Subscribe Key to publish your bot.
- Enter the Publish key and Subscribe key copied earlier from the PubNub website.
![PN 7.png Enter publish key and subscribe key](https://files.readme.io/bbf95b6-PN_7.png)
Enter publish key and subscribe key
Updated over 1 year ago