I want to integrate the Chat Bot application to ServiceNow by using the REST API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2023 03:47 AM
Hi,
I want to integrate the Chat Bot application to ServiceNow by using the REST API.
Please help me out how to do the same.
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2023 10:50 AM
Hi @SreenadhChenna ,
Hope you are doing great.
To achieve this integration:
Set up the REST API: First, ensure that your Chat Bot application has a REST API available for communication with external systems. This API should provide endpoints to send and receive messages.
Create an Integration in ServiceNow: In ServiceNow, navigate to "System OAuth > Application Registry" and create a new OAuth application for your Chat Bot integration.
Obtain OAuth Credentials: Once the integration is created, you'll receive OAuth credentials (Client ID and Client Secret) from ServiceNow.
Configure REST Message: In ServiceNow, go to "System Web Services > Outbound > REST Message" and create a new REST message. Specify the endpoint URL of your Chat Bot's REST API and set the appropriate HTTP method (e.g., POST for sending messages).
Set Authentication and Headers: set the authentication type as OAuth 2.0 and provide the Client ID and Client Secret obtained earlier
Define Payload and Variables
var restMessage = new sn_ws.RESTMessageV2();
restMessage.setHttpMethod('POST');
restMessage.setEndpoint('<Chat Bot API Endpoint URL>');
restMessage.setRequestHeader('Content-Type', 'application/json');
restMessage.setRequestHeader('Authorization', 'Bearer <Chat Bot OAuth Access Token>');
var payload = {
message: 'Hello Chat Bot!',
user: 'JohnDoe',
// Additional payload data as per your Chat Bot API requirements
};
restMessage.setRequestBody(JSON.stringify(payload));
var response = restMessage.execute();
if (response.getStatusCode() === 200) {
var responseBody = response.getBody();
// Process the response from the Chat Bot API
} else {
var errorMessage = response.getErrorMessage();
// Handle the error case appropriately
}
Regards,
Riya Verma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2023 09:08 AM
Hi @SreenadhChenna Install the Virtual API plugin if you want to integration with other chatbot integration as this is Paid plugin once you install you need to configure Message Auth and Static or hash token to get details of users from other chatbot and follow the chatbot comments.