{"id":18058,"date":"2018-08-24T11:29:43","date_gmt":"2018-08-24T11:29:43","guid":{"rendered":"https:\/\/developer.kore.ai\/v7-2\/?post_type=docs&#038;p=15176"},"modified":"2021-03-30T11:00:24","modified_gmt":"2021-03-30T10:00:24","slug":"apis","status":"publish","type":"post","link":"https:\/\/developer.kore.ai\/v7-2\/docs\/bots\/api-guide\/apis\/","title":{"rendered":"Using Kore.ai APIs"},"content":{"rendered":"<section class=\"l-section wpb_row height_auto\"><div class=\"l-section-h i-cf\"><div class=\"g-cols vc_row type_default valign_top\"><div class=\"vc_col-sm-12 wpb_column vc_column_container\"><div class=\"vc_column-inner\"><div class=\"wpb_wrapper\">\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<p>Kore.ai Bots Platform provides access to bot development using secured APIs. All key developer activities like bot creation, bot import and export, training, and publishing are available using these APIs. Key account management activities like managing Bot Builder access, managing admin and bot roles can also be performed via secured public APIs. For a complete list of APIs and usage instructions <a href=\"\/v7-2\/docs\/bots\/api-guide\/api-list\/\" target=\"_blank\" rel=\"noopener noreferrer\">refer here<\/a>.<\/p>\n<p>Authentication of the API requests involves the following two steps:<\/p>\n<ol>\n<li><b>Associate API Scopes to an App<\/b>: As a first step to allow a client application to access the Bots Platform APIs, you need to associate the client app with the bot. You could create a new app or associate an existing app. As a part of creating the app, you need to select the API scopes for the App, which allows you to provide access to only the selected APIs to the app.\n<ul>\n<li><strong>Bot Builder API Scopes<\/strong>: Bot developers can define bot specific API Scopes from the Bot Builder tool.<\/li>\n<li><strong>Bot Admin Console API Scopes<\/strong>: Account administrators can define API Scopes to access any of the bots built in their accounts from the Admin Console.<\/li>\n<\/ul>\n<\/li>\n<li><b>Generating JWT token<\/b>: To access Bot Platform\u2019s public APIs, the application making the API request requires authentication. Kore.ai uses the JWT (JSON Web Token) mechanism to handle the authentication. For a quick overview of the JWT token, read <a href=\"https:\/\/jwt.io\/introduction\/\" target=\"_blank\" rel=\"noopener noreferrer\">Introduction to JWT tokens<\/a>.<br \/>\nUse the Client ID and Client Secret of the client app from above to generate a JWT token. This token needs to be passed as a part of each API request for authorization.<\/li>\n<\/ol>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n<div class=\"w-separator size_small with_line width_default thick_1 style_solid color_border align_center\"><div class=\"w-separator-h\"><\/div><\/div>\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<h2><span class=\"ez-toc-section\" id=\"Associating_API_Scopes\">Associating API Scopes<\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"Bot_Builder\">Bot Builder<\/span><\/h3>\n<p>Following steps let you associate API Scopes to a Client App from the Bot Builder:<\/p>\n<ol>\n<li>Hover over the side-navigation panel of the bot and click <b>API Extensions<\/b>.<\/li>\n<li>On the Apps &amp; Agents page, click the <b>API Scopes<\/b> tab and then click <b>New<\/b>.<\/li>\n<li>On the New API Scope Mapping page, from the <b>App <\/b>drop-down list, select an existing client app for authentication. To create a new app, click the <b>Manage Apps<\/b> link.<\/li>\n<li>Once you select an app, the Client ID and Client Secret section appear. Copy the values.<\/li>\n<li>You can also use this screen to\u00a0<strong>delete<\/strong> apps by using the trash icon against the respective app.<\/li>\n<li>Under the Scopes section, select the APIs for which you want the client app to have access. The apps cannot access the APIs that aren\u2019t selected here.<br \/>\n<a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/13\/API-Scopes-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-15177\" src=\"\/wp-content\/uploads\/sites\/13\/API-Scopes-1.png\" alt=\"\" width=\"365\" height=\"474\" \/><\/a><\/li>\n<\/ol>\n<p><strong>NOTE<\/strong>: Once enabled, the API Scopes need to be Published. <a href=\"\/v7-2\/docs\/bots\/bot-builder-tool\/publish\/publishing-bot\/#Publishing_Tasks\" target=\"_blank\" rel=\"noopener noreferrer\">Follow the Publish<\/a> procedure ensuring that the API Scopes are selected from the API Extensions option.<\/p>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n<div class=\"w-separator size_small with_line width_default thick_1 style_solid color_border align_center\"><div class=\"w-separator-h\"><\/div><\/div>\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<h3><span class=\"ez-toc-section\" id=\"Bot_Admin_Console\">Bot Admin Console<\/span><\/h3>\n<p>Following steps let you associate API Scopes to a Client App from the Bot Admin Console:<\/p>\n<ol>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">On the side-navigation panel of the Bots Admin homepage, click <\/span><b>Security &amp; Control &gt; API Scopes<\/b><span style=\"font-weight: 400\">.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">On the API Scopes page, click <\/span><b>New<\/b><span style=\"font-weight: 400\">.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">On the New API Scope Mapping page, from the <\/span><b>App <\/b><span style=\"font-weight: 400\">drop-down list, select an existing client app for authentication. To create a new app, click the<\/span><b> Manage Apps <\/b><span style=\"font-weight: 400\">link. <\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Once you select an app, the <\/span><i><span style=\"font-weight: 400\">Client ID and Client Secret<\/span><\/i><span style=\"font-weight: 400\"> section appear. Copy the values.<\/span><\/li>\n<li>You can also use this screen to\u00a0<strong>delete<\/strong> apps by using the trash icon against the respective app.<\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Under the Scopes section, select the APIs for which you want the client app to have access.<\/span><\/li>\n<\/ol>\n<h3><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-15659 aligncenter\" src=\"\/wp-content\/uploads\/sites\/13\/Admin-Console-App-Scopes-276x300.png\" alt=\"\" width=\"276\" height=\"300\" \/><\/h3>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n<div class=\"w-separator size_small with_line width_default thick_1 style_solid color_border align_center\"><div class=\"w-separator-h\"><\/div><\/div>\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<h2><span class=\"ez-toc-section\" id=\"Generating_JWT_Token\">Generating JWT Token<\/span><\/h2>\n<p>Once you have associated the API scopes to a client app, you need to generate JWT token for API requests.<\/p>\n<ol>\n<li>Go to <a href=\"http:\/\/jwt.io\">http:\/\/jwt.io<\/a> and scroll down the page to the Decoded section.<br \/>\n<a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/13\/JWT-page-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-15178\" src=\"\/wp-content\/uploads\/sites\/13\/JWT-page-1.png\" alt=\"\" width=\"353\" height=\"367\" \/><\/a><\/li>\n<li>Replace the contents in the <b>Payload <\/b>box with the Client ID of the app copied in the previous section.<br \/>\n<a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/13\/App-ID-2.png\" rel=\"attachment wp-att-15590\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-15590\" src=\"\/wp-content\/uploads\/sites\/13\/App-ID-2.png\" alt=\"\" width=\"513\" height=\"125\" \/><\/a><\/p>\n<div class=\"alert alert-info\">Note: The Bot Builder validates the token only when it is generated exactly as \u201cappId\u201d. The platform doesn&#8217;t validate tokens generated with any other formats such as \u201cApp ID\u201d \u201cappid\u201d or \u201capp ID\u201d.<\/div>\n<\/li>\n<li>In the <strong>Verify Signature<\/strong> box, enter the Client Secret copied from the previous section in the box with the text <b>your-256-bit-secret<\/b>.<br \/>\n<a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/13\/Client-secrte-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-15180\" src=\"\/wp-content\/uploads\/sites\/13\/Client-secrte-1.png\" alt=\"\" width=\"463\" height=\"163\" \/><\/a><\/li>\n<li>Copy the generated JWT token from the Encoded section on the left.<br \/>\n<a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/13\/Encoded-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-15181\" src=\"\/wp-content\/uploads\/sites\/13\/Encoded-1.png\" alt=\"\" width=\"459\" height=\"169\" \/><\/a><\/li>\n<li>This token can be used to access the required API and it needs to be passed as a part of each API request for authorization.<\/li>\n<li>You can use the API Collection to test the APIs from your Postman setup. <a href=\"\/v7-2\/docs\/bots\/api-guide\/api-collection\/\" target=\"_blank\" rel=\"noopener noreferrer\">See here for more<\/a>.<\/li>\n<\/ol>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n<div class=\"w-separator size_small with_line width_default thick_1 style_solid color_border align_center\"><div class=\"w-separator-h\"><\/div><\/div><\/div><\/div><\/div><\/div><\/div><\/section>\n","protected":false},"excerpt":{"rendered":"Kore.ai Bots Platform provides access to bot development using secured APIs. All key developer activities like bot creation, bot import and export, training, and publishing are available using these APIs. Key account management activities like managing Bot Builder access, managing admin and bot roles can also be performed via secured public APIs. For a complete...","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"class_list":["post-18058","post","type-post","status-publish","format-standard","hentry","category-api-guide"],"_links":{"self":[{"href":"https:\/\/developer.kore.ai\/v7-2\/wp-json\/wp\/v2\/posts\/18058","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/developer.kore.ai\/v7-2\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/developer.kore.ai\/v7-2\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/developer.kore.ai\/v7-2\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/developer.kore.ai\/v7-2\/wp-json\/wp\/v2\/comments?post=18058"}],"version-history":[{"count":10,"href":"https:\/\/developer.kore.ai\/v7-2\/wp-json\/wp\/v2\/posts\/18058\/revisions"}],"predecessor-version":[{"id":22938,"href":"https:\/\/developer.kore.ai\/v7-2\/wp-json\/wp\/v2\/posts\/18058\/revisions\/22938"}],"wp:attachment":[{"href":"https:\/\/developer.kore.ai\/v7-2\/wp-json\/wp\/v2\/media?parent=18058"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/developer.kore.ai\/v7-2\/wp-json\/wp\/v2\/categories?post=18058"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/developer.kore.ai\/v7-2\/wp-json\/wp\/v2\/tags?post=18058"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}