Skip to main content

Conversation: Get History Tool

Usage

All Portia tools using API endpoints that require OAuth are built with plug and play authentication support. They use Portia client credentials including client ID, client name and redirect URL. Such tools will raise a Action Clarification with an OAuth link as the action URL. The portia.wait_for_ready() method must be used in this scenario: Portia's OAuth server will listen for the authentication result and resolve the concerned clarification, allowing your plan run to resume again.

For more on this, please visit to the section on running Portia tools ().

Configure your Slack tools with Portia AI

You will need to create your own Slack App to use with Portia AI. This is so you can control the name and appearance of slack bot activity initiated via the Portia AI framework. Once your slack app is created you can configure your client ID and secret in the Portia dashboard.

Install a Slack app

  1. Head over to api.slack.com/apps ↗
  2. Create an app from scratch and select the Slack workplace you would like to use it in.
  3. Note down the client ID and secret on the Basic Information page. We will need this in a couple of steps from now!
  4. In the OAuth & Permissions tab further down in the left hand nav, add as Redirect URL the following URL https://api.portialabs.ai/api/v0/oauth/slack (don't forget to hit that Save URLs button!).
  5. Under Bot Token Scopes, be sure to add the scopes
    • channels:history -- View messages and other content in public channels that your Slack app has been added to.
    • channels:read -- View basic information about public channels in a workspace.
    • chat:write -- Send messages as @{your slack app name}.
    • users:read -- View people in a workspace.
  6. Under User Token Scopes, be sure to add the scope search:read to support searching workplace content.
  7. Now scroll up to the top of the OAuth & Permissions page and hit the Install to {your workplace name} button.
  8. Once that is done, open your Slack app and hit 'Add apps` and be sure to select your new app.

Configure access in Portia AI

  1. Log into your Portia dashboard ↗
  2. Navigate to the Manage Org tab.
  3. Enter the client ID and secret of your Slack app as collected in step 3 of the Slack installation process above.

You are now ready to call Slack tools on our cloud!

Tool details

Tool ID: portia:slack:user:conversation_history

Tool description: Get the conversation history for a given channel by channel id. Requires an ID typically from the list_conversation_ids tool.

Args schema:

{
"description": "Input for GetSlackConversationTool.",
"properties": {
"channel_id": {
"description": "The channel/group/private message id to get the conversation history for.",
"title": "Channel Id",
"type": "string"
},
"limit": {
"default": 20,
"description": "The maximum number of messages to return. Default is 20. Too many messages cancause the context window to be exceeded.",
"title": "Limit",
"type": "integer"
}
},
"required": [
"channel_id"
],
"title": "GetSlackConversationToolSchema",
"type": "object"
}

Output schema:

('dict', 'dict: Object per message with text, user, and replies if follow_threads is true')