Message: Find 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
- Head over to api.slack.com/apps ↗
- Create an app from scratch and select the Slack workplace you would like to use it in.
- Note down the client ID and secret on the Basic Information page. We will need this in a couple of steps from now!
- 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!). - 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.
- Under User Token Scopes, be sure to add the scope
search:read
to support searching workplace content. - Now scroll up to the top of the OAuth & Permissions page and hit the Install to {your workplace name} button.
- 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
- Log into your Portia dashboard ↗
- Navigate to the Manage Org tab.
- 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:find_message
Tool description: Search for a message in a Slack channel or chat.
Args schema:
{
"description": "Input for FindMessageTool.",
"properties": {
"target": {
"description": "Slack channel ID (i.e. C084F1FSTFC), channel name (#slack-tool-testing)or user name (@tom) that the messages were sent to.",
"title": "Target",
"type": "string"
},
"query": {
"default": "",
"description": "When using the Slack Find Message tool to search for messages you have to adhere to the query string structure of slack strictly. In addition to whatever keywords are relevant from the user's prompt, follow the guidelines below to build the query string and never ever add anything other than that. To look for messages from a specific user you have to refer to their slack user name using @ in the query string like so: 'from:@UserName' e.g. 'from:@nathan' to get messages from nathan. To look for messages sent to me or someone else you have to refer to their Slack username using @ in the query string like so: 'to:@UserName' e.g. 'to:@mounir'. Next, and this should ONLY be used if the user is asking about messages in a specific channel, to look for messages in a specific channel you have to insert 'in:ChannelName' in the query string e.g. 'in:social'",
"title": "Query",
"type": "string"
}
},
"required": [
"target"
],
"title": "FindSlackMessageToolSchema",
"type": "object"
}
Output schema:
('dict', 'dict: Output of the messages found')