#Shopify Update Order is missing input options due to a lack of recognizing GraphQL
1 messages · Page 1 of 1 (latest)
Yes, updating the actions to use the GraphQL APIs is in the pipeline. I’m checking with the team about extending it manually and will get back to you soon!
Hi Daniel! We support creating custom tools, where in you can define your own logic & just need to specify the tool-name & the auth would be injected, learn more here: https://docs.composio.dev/tool-calling/custom-tools
Here's the snippet for creating Custom action for Shopify. It gets the Shop details (GraphQL APIs):
import typing as t
from composio_openai import ComposioToolSet, action
from openai import OpenAI
client = OpenAI(
api_key="<openai-api-key>"
)
toolset = ComposioToolSet(api_key="<composio-api-key")
@action(toolname="shopify")
def get_shop_details_custom(
execute_request: t.Callable,
) -> dict:
"""
Gets the details of a shop in shopify
:return shop: Return shop detail
"""
query = """
{
shop {
name
email
primaryDomain {
url
host
}
currencyCode
}
}
"""
response = execute_request(
endpoint="https://<shopify-sub-domain>.myshopify.com/admin/api/2023-04/graphql.json",
method="POST",
body={"query": query},
# parameters=None,
)
return response
tools = toolset.get_tools(actions=[get_shop_details_custom])
question = "Get details about my Shopify Shop"
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": question}],
tools=tools,
tool_choice="auto",
)
result = toolset.handle_tool_calls(response=response)
print(result)
Lmk if you need any assistance!
Thanks for the info! Can anyone from the devs explain how I can pass in authentication params from what's stored in Composio's connectedAccounts into a custom tool action? Say I want to extend manually what you currently support in Shopify (just like in my case, I want to support canceling an order or updating an order with more params but keeping the existing account).
I tried creating the tool but there is an issue with the AuthCreds in the callback url
authCredentials: {
headers: {
Authorization: 'Bearer ya29.*****hfjQ0177',
'x-request-id': '2807******4c'
},
queryParams: {},
baseUrl: 'https://www.googleapis.com'
}
If anyone from the team can take a look at the above 🙏
@paper ridge Taking a look at it
Hey @paper ridge, thanks for bringing this to our attention—There's a bug on our end preventing automatic auth injection.
Until we fix this, please use the snippet below (this is an example for getting shop details, you can make changes acc to your usecase).
import { LangchainToolSet } from "composio-core"
const toolset = new LangchainToolSet({ apiKey: "{{composio-api-key}}" }) //add you composio-api-key here
await toolset.createAction({
actionName: 'get_shop_details_custom',
toolName: 'shopify',
description: 'Get the details of a shop in Shopify',
callback: async (inputParamsZod, authCredentials, executeRequest) => {
const mutation = `
{
shop {
name
email
primaryDomain {
url
host
}
currencyCode
}
}
`;
try {
const responseData = await executeRequest({
endpoint: 'https://{{shopify-subdomain}}.myshopify.com/admin/api/2023-04/graphql.json', //add your shopif subdomain here
method: 'POST',
parameters: [{ name: 'Content-Type', value: 'application/json', in: 'header' },
{
name: 'X-Shopify-Access-Token',
value: "{{your-access-token}}", //add your access token here
in: 'header',
},],
body: { query: mutation },
});
return {
data: responseData,
successful: true
};
} catch (e) {
console.log(e);
return {
data: {},
successful: false
};
}
},
})
const res = await toolset.executeAction({ action: "get_shop_details_custom" })
console.log("res :: ", JSON.stringify(res));
I'll update you once the issue is resolved!
@idle kestrel thanks! The issue with this is that I have multiple "entities" / customers, it will fix it only for that customer but not all.
Yes, that's understandable. Our team is working on fixing this. I'll notify you once it's live!
Is there a board to see the progress on this? how much of a priority is it / when expected to be solved?
We don’t have a progress board ATM—this is a high priority and you can expect this to he fixed within 48hrs.
Hey @paper ridge , the issue has been fixed—Please use [email protected]
I've attached the code snippet for ref—Note that I've added the extractSubdomain() to extract the subdomain of user's Shopify Acc and dynamically passing it in the endpoint arg, this is because our Shopify tool uses Shopify's REST APIs & the endpoint is different for GraphQL.
LMK if you need any help—happy to assist!
what about authentication data (token etc)?
Auth would be injected automatically!